const Sequelize = require('sequelize');
const sequelize = require('../libs/sequelize')


const Artist = sequelize.define('artist', {
    id: {
        type: Sequelize.INTEGER,
        allowNull: true,
        primaryKey: true,
        autoIncrement: true
    },
    name: {
        type: Sequelize.STRING
    },
    avatar: {
        type: Sequelize.STRING,
        allowNull: true
    },
    nickname: {
        type: Sequelize.STRING,
        allowNull: true
    },
    desc: {
        type: Sequelize.STRING,
        allowNull: true
    }

});

// force: true 如果表已经存在，将会丢弃表
// Artist.sync({ force: true }).then(() => {

//     console.log('done ')

// });


// Artist.create({
//     name: 'xxx',
//     nickname: 'xxxx',
//     desc: 'xxx',
//     avatar: 'xxx'
// }).then((result) => {
//     return Promise.all([
//         Album.create({
//             name: 'xxxx',
//             poster: 'xxx',
//             publishDate: '2017-02-02',
//             playCount: 20,
//             artist_id: result.id
//         }),
//         Album.create({
//             name: 'xxxx',
//             poster: 'xxx',
//             publishDate: '2017-02-02',
//             playCount: 20,
//             artist_id: result.id
//         })
//     ])
// })

module.exports = Artist